<%@ page language="java" import="java.util.*,dao.*,dao.impl.*,entity.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	BoardDao boardDao = new BoardDaoImpl();
	TopicDao topicDao = new TopicDaoImpl();
	UserDao userDao = new UserDaoImpl();
	Map mapBoard = boardDao.findBoard();
 %>
<!doctype html>
<html>
<head>
<base href="<%=basePath%>">
<meta charset="utf-8">
<title>首页</title>
<style type="text/css">
body,td,th {

	font-style: normal;
}
#Div1{
    position:absolute;
    left: 1px;
    top: 1px;
    width: 800px;
    height: 50px;
    z-index: 1;
}
#Div2{
    position: absolute;
    left: 1px;
    top: 51px;
    width: 800px;
    height: 25px;
    z-index: 2;
}
#Div3{
    position: absolute;
    left: 1px;
    top: 76px;
    width: 800px;
    height: 500px;
    z-index: 3;
}
.STYLE1{
    font-family: "黑体";
    font-weight: bold;
    font-size: 36px;
    color: #3399cc;
}
.STYLE3{
    font-family: "黑体";
    font-weight: bold;
    font-size: 36px;
    color: #3399cc;
}
.STYLE4{
    color: #004c7d;
    font-size: 12px;
}
</style>
<link href="style.css" rel="stylesheet" type="text/css" media="screen">
</head>

<body>
<div id="Div1">
  <div align="center" class="STYLE1" style="width: 800px; height: 50px; background-color: #FFFFFF; z-index: 1; font-style: normal; font-weight: normal; font-size: 24px; text-align: center;">校园BBS系统</div>
</div>
<div class="STYLE4" id="Div2">
  <div style="width: 800px; height: 25px; background-color: #E0F0F9; z-index: 2; font-size: 12px; color: #000000;">
	您尚未 <a href="html/login.html" target="_blank">登录</a>|
	  <a href="reg.html" target="_blank">注册</a>
</div>
</div>
<div id="Div3_h800">
  <div style="width: 800px; height: 500px; background-color: #ffffff; z-index: 1; font-size: 12px; color: #004C7D;">
    <table width="100%" hight="503" border="1" cellspacing="0" cellpadding="0">
      <tbody>
        <tr>
          <td colspan="2" align="left" valign="middle"><span class="STYLE4">论坛</span></td>
<!--			colspan="2" 将这个格子的宽度变为2格宽，合并单元格效果-->
          <td width="5%" class="STYLE4">主题</td>
          <td width="45%" class="STYLE4">最后发表</td>
        </tr>
        <!-- 主板块 -->
        <% 
        List listMainBoard = (List)mapBoard.get(new Integer(0));
            for(int i = 0;i<listMainBoard.size();i++) {
                Board mainBoard = ((Board) listMainBoard.get(i));//循环获得主版块

        %>
        <tr>
          <td colspan="4" class="STYLE4"><%= mainBoard.getBoardName() %></td>
        </tr>
        
        <!--子版块  --> 
        <%
        	List listSonBoard = (List)mapBoard.get(new Integer(mainBoard.getBoardId()));
        	for(int j = 0;j<listSonBoard.size();j++){
        		Board sonBoard = (Board)listSonBoard.get(j);
        		Topic topic = new Topic();
        		User user = new User();
        		int boardId = sonBoard.getBoardId();
        		List listTopic = topicDao.findListTopic(1, boardId);
        		if(listTopic!=null && listTopic.size()>0){
        		topic = (Topic)listTopic.get(0);
        		user = userDao.findUser(topic.getUid());
        		}	
         %>
        <tr>
          <td width="6%">&nbsp;</td>
          <td width="44%"><%=sonBoard.getBoardName() %></td>
          <td>&nbsp;</td>
          <td>&nbsp;</td>
        </tr>
        <%
        }
        }
         %>
      </tbody>
    </table>
  </div>
</div>
</body>
</html>
